﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DatabaseAccessLayer;

namespace WebApplication
{
    public partial class Requests_Results : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Master.FindControl("RightAdvertisement").Visible = false;
            if (!IsPostBack)
            {
                fillGrid();
            }
            ((System.Web.UI.HtmlControls.HtmlGenericControl)Master.FindControl("divbreadcrum")).InnerHtml = @"<a href='default.aspx'>Home</a> >  <a href='menu.aspx'>Menu</a> > <a href='real_estate_search.aspx'>Real Estate Search</a> >  <a href='javascript:void();' onclick='history.go(-1);'>Real Estate Search Menu</a> > <span>Request Results</span> ";
            h3Header.InnerHtml = string.Concat(Request["co"], " - ", Request["s"], " - ", Request["c"], "- Real Estate Requests"); 
        }

        protected void fillGrid()
        {
            string country = Request["co"];
            string city = Request["c"];
            List<PostOfferRequestSt> lst = PostOfferRequest.SearchResult(country,city);
            if (lst.Count > 0)
            {
                gvResidentail.DataSource = lst;
                gvResidentail.DataBind();
                dvresult.Visible = true;
            }
            else
            {
                gvResidentail.EmptyDataText = "No Result found";
                dvresult.Visible = false;
            }

        }
        protected void gvResidentail_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                // Display the company name in italics.
                if (Session["IsMember"] == null || Session["IsMember"].ToString() != "True")
                {
                    ((Label)e.Row.Cells[8].FindControl("lblContactName")).Text = "Savory Housing";
                    ((Label)e.Row.Cells[8].FindControl("lblContactNo1")).Text = "00966507040123";
                    ((Label)e.Row.Cells[9].FindControl("lblContactNo2")).Text = "TBD";
                }
            }

        }
    }
}